Creating an instance of MyDataSource

This section assumes you are already familiar with how to pass a new data source to the Active Data Driver at runtime. If you need more information on using the Active Data Driver, refer to Active Data Driver. The following steps simply illustrate how to assign the myDs object created above to the Active Data Driver so that a report will use it as the source of data at runtime.

To actually use the MyDataSourcePrj component, you must create an instance of the MyDataSource object, then assign that object to the Report object displayed by your application. Assuming you created a report in your application using the Crystal Designer Component and accepted default settings for adding the Crystal Report Viewer/ActiveX to your project:

  1. Open the code window for the form containing the CrystalReport Viewer/ActiveX.
  2. In the General Declarations section for the form, add the following code:

    Dim myDs As New MyDataSourcePrj.MyDataSource

  3. In the Form_Load procedure, add the following line before the Report object is assigned to the ReportSource property of the CRViewer1 object:

    CRXReport.Database.SetDataSource myDs,3, 1

Note:    This example is based on a Visual Basic application created using the Report Designer Component. for more information see Report Designer Component Object Model.

The first line of code creates an instance of the MyDataSource object in your application, much like you might create an instance of an ADO Recordset object. The second line of code added uses the SetDataSource method inside the Crystal Designer Component library to dynamically change the source of data used by your report.

If you designed your report using an ADO, DAO, or RDO data source, or by using a Data Definition file, then your report uses the Active Data Driver to access the report data at runtime. Since the Active Data Driver also supports data sources that expose the Crystal Data Source interface, you can easily assign the MyDataSource object to your report.



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com